import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
// import Layout from '@/layout'
import energyMonitoringRouter from './modules/energy-monitoring'  //能源监测
import informationEntryRouter from './modules/information-entry'  //信息录入
import statisticalReportsRouter from './modules/statistical-reports' //统计报表
import basicinformationManagementRouter from './modules/basic-information-management'  //基础信息
// import systemManagementRouter from './modules/system-management' //系统管理
export const constantRoutes = [
  {
    path: '/',
    redirect: '/login',
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/loading-module',
    component: () => import('@/views/loading-module'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  }
]
export const asyncRoutes = [
  energyMonitoringRouter, //能源监测
  informationEntryRouter, //信息录入
  statisticalReportsRouter, //统计报表
  basicinformationManagementRouter, //基础信息
  // systemManagementRouter, //系统管理
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
